package com.jiahua.comm.interceptor;

import java.util.logging.Logger;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class MyParameterInterceptor implements Interceptor {
	private static final long serialVersionUID = 1L;

	final Logger logger = Logger.getLogger(MyLoggingInterceptor.class.getName());

	public String intercept(ActionInvocation actionInvocation) throws Exception {

		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		HttpSession session = ServletActionContext.getRequest().getSession();

		logger.info("After calling action: request " + request + "response: " + response + " , session : " + session);

		String result = actionInvocation.invoke();
		logger.info("result  : " + result);

		return result;
	}

	public void destroy() {
		logger.info("Destroying MyParameterInterceptor...");
	}

	public void init() {
		logger.info("Initializing MyParameterInterceptor...");
	}

}